Repository navigation
fix(cocoa): native events dropped by managed callbacks are no longer counted twice in client reports - #6055
Conversation
…ient reports sentry-cocoa already records a before_send discard when the managed BeforeSend bridge returns nil, so skip the .NET record for native events. Closes #5681 Co-Authored-By: Claude <noreply@anthropic.com>
PR risk: mediumFor commit Main concerns: reach, public contract, data sent to Sentry. This label is a hint for reviewers, not an approval. |
There was a problem hiding this comment.
Good to approve and merge
Fixes the cause of #5681: the Cocoa bridge stops recording client reports for native events that managed processors or BeforeSend drop, and leaves counting to sentry-cocoa, which records before_send when the callback returns nil. Managed capture paths keep the default recordDiscards: true, the change is internal-only, and the new iOS test covers null and throwing callbacks for both processors and BeforeSend. This matches the Android bridge, which already leaves counting to sentry-java.
This is an automated preliminary review.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #6055 +/- ##
=======================================
Coverage 78.33% 78.33%
=======================================
Files 537 537
Lines 20134 20138 +4
Branches 4055 4059 +4
=======================================
+ Hits 15771 15776 +5
+ Misses 3516 3514 -2
- Partials 847 848 +1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
ric-oliv
left a comment
There was a problem hiding this comment.
What do you think about fix(cocoa): for the title? The bridge also compiles for Mac Catalyst, and #5943 used cocoa for the same function, so Catalyst users would see the fix in the changelog too.
The description mentions that a throwing callback now shows up only as before_send. A processor that returns null on a native event changes reason too, from event_processor to before_send. Maybe add a sentence? The #5681 table already covers it, so I'm fine either way.
Summary
On iOS,
ProcessOnBeforeSendruns the managed event processors andBeforeSendon native events. When one of them drops the event, .NET recorded a client report discard and returned nil. sentry-cocoa then recordedbefore_sendfor the same event, so each drop was counted twice.SentryEventHelper.ProcessEventandDoBeforeSendnow take arecordDiscardsflag. The Cocoa bridge passesfalse, which leaves the counting to sentry-cocoa, as decided in #5634. Managed events are unchanged.Until sentry-cocoa can record
callback_error(getsentry/sentry-cocoa#8993), a callback that throws on a native iOS event shows up only asbefore_send. An event processor that returnsnullon a native event is also now counted asbefore_sendrather thanevent_processor.The new iOS test passed on the simulator via
scripts/device-test.ps1 ios.Closes #5681
🤖 Generated with Claude Code